Skip to content

Implement tom-select for related documents #6610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

smithellis
Copy link
Contributor

@smithellis smithellis commented Apr 2, 2025

  • Don't allow addition of article to it's own related
  • Don't show old checkbox list on edit or new document pages
  • On document view pages, don't show restricted articles in the related documents section if the user lacks permissions

This should fix 2259, 2260, 2261

@smithellis smithellis marked this pull request as ready for review April 2, 2025 16:10
@smithellis smithellis requested a review from Copilot April 2, 2025 16:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements Tom Select for improved related documents management while adding filtering to exclude the current and restricted documents.

  • Replaces the old checkbox list with a Tom Select based search input on edit and new document pages.
  • Updates search queries and results to include document IDs and the is_restricted flag.
  • Introduces the is_restricted field in the search index for documents.

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.

File Description
kitsune/sumo/static/sumo/js/wiki_search.js Refactors the UI to integrate Tom Select and filters documents based on current document and is_restricted status.
kitsune/search/search.py Propagates the is_restricted flag in the search result.
kitsune/search/documents.py Adds a new Boolean is_restricted field and its preparation method for documents.
Files not reviewed (2)
  • kitsune/sumo/static/sumo/scss/components/_wiki.scss: Language not supported
  • kitsune/wiki/jinja2/wiki/includes/related_docs_widget.html: Language not supported
Comments suppressed due to low confidence (1)

kitsune/sumo/static/sumo/js/wiki_search.js:75

  • Consider ensuring that both item.id and currentDocId have consistent types by converting them (for example, using parseInt) and using strict equality (!==) to avoid potential type coercion issues.
.filter(item => !currentDocId || item.id != currentDocId)

- Don't allow addition of article to it's own related
- Don't show old checkbox list on edit or new document pages
- Exclude restricted documents from viewing in
related documents section of article page
@smithellis smithellis force-pushed the improve-related-documents-functionality branch from 98bb364 to c37c0bf Compare April 7, 2025 21:29
@smithellis smithellis self-assigned this Apr 8, 2025
@smithellis smithellis requested a review from Copilot April 8, 2025 01:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (3)
  • kitsune/sumo/static/sumo/scss/components/_wiki.scss: Language not supported
  • kitsune/wiki/jinja2/wiki/includes/document_macros.html: Language not supported
  • kitsune/wiki/jinja2/wiki/includes/related_docs_widget.html: Language not supported
Comments suppressed due to low confidence (1)

kitsune/sumo/static/sumo/js/wiki_search.js:87

  • The render.item function both appends the rendered template to $relatedDocsList and returns an HTML string, which might result in duplicate rendering of the same item. Consider removing the side-effect append so that rendering is handled solely by the return value.
$relatedDocsList.append(nunjucksEnv.render('wiki-related-doc.njk', context));

@smithellis smithellis self-assigned this May 6, 2025
@smithellis smithellis requested review from akatsoulas and escattone May 6, 2025 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes search results are not returned inside the "Related documents" section
1 participant